// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed partial class DataframeEvaluationClassification : IDataframeEvaluationVariant
	{
		[JsonInclude]
		[JsonPropertyName("actual_field")]
		public Elastic.Clients.Elasticsearch.Field ActualField { get; set; }

		[JsonInclude]
		[JsonPropertyName("metrics")]
		public Elastic.Clients.Elasticsearch.Ml.DataframeEvaluationClassificationMetrics? Metrics { get; set; }

		[JsonInclude]
		[JsonPropertyName("predicted_field")]
		public Elastic.Clients.Elasticsearch.Field? PredictedField { get; set; }

		[JsonInclude]
		[JsonPropertyName("top_classes_field")]
		public Elastic.Clients.Elasticsearch.Field? TopClassesField { get; set; }
	}

	public sealed partial class DataframeEvaluationClassificationDescriptor<TDocument> : SerializableDescriptorBase<DataframeEvaluationClassificationDescriptor<TDocument>>
	{
		internal DataframeEvaluationClassificationDescriptor(Action<DataframeEvaluationClassificationDescriptor<TDocument>> configure) => configure.Invoke(this);
		public DataframeEvaluationClassificationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Field ActualFieldValue { get; set; }

		private Elastic.Clients.Elasticsearch.Ml.DataframeEvaluationClassificationMetrics? MetricsValue { get; set; }

		private DataframeEvaluationClassificationMetricsDescriptor MetricsDescriptor { get; set; }

		private Action<DataframeEvaluationClassificationMetricsDescriptor> MetricsDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Field? PredictedFieldValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? TopClassesFieldValue { get; set; }

		public DataframeEvaluationClassificationDescriptor<TDocument> ActualField(Elastic.Clients.Elasticsearch.Field actualField)
		{
			ActualFieldValue = actualField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> ActualField<TValue>(Expression<Func<TDocument, TValue>> actualField)
		{
			ActualFieldValue = actualField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> Metrics(Elastic.Clients.Elasticsearch.Ml.DataframeEvaluationClassificationMetrics? metrics)
		{
			MetricsDescriptor = null;
			MetricsDescriptorAction = null;
			MetricsValue = metrics;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> Metrics(DataframeEvaluationClassificationMetricsDescriptor descriptor)
		{
			MetricsValue = null;
			MetricsDescriptorAction = null;
			MetricsDescriptor = descriptor;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> Metrics(Action<DataframeEvaluationClassificationMetricsDescriptor> configure)
		{
			MetricsValue = null;
			MetricsDescriptor = null;
			MetricsDescriptorAction = configure;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> PredictedField(Elastic.Clients.Elasticsearch.Field? predictedField)
		{
			PredictedFieldValue = predictedField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> PredictedField<TValue>(Expression<Func<TDocument, TValue>> predictedField)
		{
			PredictedFieldValue = predictedField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> TopClassesField(Elastic.Clients.Elasticsearch.Field? topClassesField)
		{
			TopClassesFieldValue = topClassesField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor<TDocument> TopClassesField<TValue>(Expression<Func<TDocument, TValue>> topClassesField)
		{
			TopClassesFieldValue = topClassesField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("actual_field");
			JsonSerializer.Serialize(writer, ActualFieldValue, options);
			if (MetricsDescriptor is not null)
			{
				writer.WritePropertyName("metrics");
				JsonSerializer.Serialize(writer, MetricsDescriptor, options);
			}
			else if (MetricsDescriptorAction is not null)
			{
				writer.WritePropertyName("metrics");
				JsonSerializer.Serialize(writer, new DataframeEvaluationClassificationMetricsDescriptor(MetricsDescriptorAction), options);
			}
			else if (MetricsValue is not null)
			{
				writer.WritePropertyName("metrics");
				JsonSerializer.Serialize(writer, MetricsValue, options);
			}

			if (PredictedFieldValue is not null)
			{
				writer.WritePropertyName("predicted_field");
				JsonSerializer.Serialize(writer, PredictedFieldValue, options);
			}

			if (TopClassesFieldValue is not null)
			{
				writer.WritePropertyName("top_classes_field");
				JsonSerializer.Serialize(writer, TopClassesFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class DataframeEvaluationClassificationDescriptor : SerializableDescriptorBase<DataframeEvaluationClassificationDescriptor>
	{
		internal DataframeEvaluationClassificationDescriptor(Action<DataframeEvaluationClassificationDescriptor> configure) => configure.Invoke(this);
		public DataframeEvaluationClassificationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Field ActualFieldValue { get; set; }

		private Elastic.Clients.Elasticsearch.Ml.DataframeEvaluationClassificationMetrics? MetricsValue { get; set; }

		private DataframeEvaluationClassificationMetricsDescriptor MetricsDescriptor { get; set; }

		private Action<DataframeEvaluationClassificationMetricsDescriptor> MetricsDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Field? PredictedFieldValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? TopClassesFieldValue { get; set; }

		public DataframeEvaluationClassificationDescriptor ActualField(Elastic.Clients.Elasticsearch.Field actualField)
		{
			ActualFieldValue = actualField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor ActualField<TDocument, TValue>(Expression<Func<TDocument, TValue>> actualField)
		{
			ActualFieldValue = actualField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor ActualField<TDocument>(Expression<Func<TDocument, object>> actualField)
		{
			ActualFieldValue = actualField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor Metrics(Elastic.Clients.Elasticsearch.Ml.DataframeEvaluationClassificationMetrics? metrics)
		{
			MetricsDescriptor = null;
			MetricsDescriptorAction = null;
			MetricsValue = metrics;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor Metrics(DataframeEvaluationClassificationMetricsDescriptor descriptor)
		{
			MetricsValue = null;
			MetricsDescriptorAction = null;
			MetricsDescriptor = descriptor;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor Metrics(Action<DataframeEvaluationClassificationMetricsDescriptor> configure)
		{
			MetricsValue = null;
			MetricsDescriptor = null;
			MetricsDescriptorAction = configure;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor PredictedField(Elastic.Clients.Elasticsearch.Field? predictedField)
		{
			PredictedFieldValue = predictedField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor PredictedField<TDocument, TValue>(Expression<Func<TDocument, TValue>> predictedField)
		{
			PredictedFieldValue = predictedField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor PredictedField<TDocument>(Expression<Func<TDocument, object>> predictedField)
		{
			PredictedFieldValue = predictedField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor TopClassesField(Elastic.Clients.Elasticsearch.Field? topClassesField)
		{
			TopClassesFieldValue = topClassesField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor TopClassesField<TDocument, TValue>(Expression<Func<TDocument, TValue>> topClassesField)
		{
			TopClassesFieldValue = topClassesField;
			return Self;
		}

		public DataframeEvaluationClassificationDescriptor TopClassesField<TDocument>(Expression<Func<TDocument, object>> topClassesField)
		{
			TopClassesFieldValue = topClassesField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("actual_field");
			JsonSerializer.Serialize(writer, ActualFieldValue, options);
			if (MetricsDescriptor is not null)
			{
				writer.WritePropertyName("metrics");
				JsonSerializer.Serialize(writer, MetricsDescriptor, options);
			}
			else if (MetricsDescriptorAction is not null)
			{
				writer.WritePropertyName("metrics");
				JsonSerializer.Serialize(writer, new DataframeEvaluationClassificationMetricsDescriptor(MetricsDescriptorAction), options);
			}
			else if (MetricsValue is not null)
			{
				writer.WritePropertyName("metrics");
				JsonSerializer.Serialize(writer, MetricsValue, options);
			}

			if (PredictedFieldValue is not null)
			{
				writer.WritePropertyName("predicted_field");
				JsonSerializer.Serialize(writer, PredictedFieldValue, options);
			}

			if (TopClassesFieldValue is not null)
			{
				writer.WritePropertyName("top_classes_field");
				JsonSerializer.Serialize(writer, TopClassesFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}
}